import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../components/Login.vue'
import ElementUI from '../components/ElementUI.vue'
import Home from '../components/Home.vue'
import Register from '../components/Register.vue'
import User from '../components/user/user.vue'
import Customer from '../components/user/customer/customer.vue'
import AutoCity from '../components/user/customer/autocity.vue'
import Flashguest from '../components/user/customer/flashguest.vue'
import Supplier from '../components/user/supplier/supplier.vue'
import Privatecar from '../components/user/customer/privatecar.vue'
import Index from '../components/project/index.vue'
import Shopping from '../components/project/shopping.vue'
import List from '../components/project/list.vue'
import About from '../components/project/about.vue'
import Item from '../components/items/Item.vue'
import ItemAll from '../components/items/ItemAll.vue'
import ItemCat from '../components/items/ItemCat.vue'
import Yinlianbang from '../components/voitems/Yinlianbang.vue'
import Yinlianbang1 from '../components/voitem/Yinlianbang1.vue'
import AddYinglianbang from '../components/items/item/addYinglianbang.vue'
/* 统计 */
import Show from '../components/report/show.vue'
import Ylbbing from '../components/report/ylb_bing.vue'
/* 个人中心 */
import Me from '../components/project/me.vue'
import Carshopping from '../components/people/carshopping.vue'
import PersonalData from '../components/people/personalData.vue'
import Usernew from '../components/people/usernew.vue'
import Favorites from '../components/people/favorites.vue'
/* 仓库 */
import Storehousebig from '../components/warehouse/storehousebig.vue'
import Storehousesmall from '../components/warehouse/storehousesmall.vue'
/* 车型查询 */
import Car from '../components/project/car.vue'
import Carmall from '../components/cars/carmall.vue'
import Cardetail from '../components/cars/cardetail.vue'
import AddcarItem from '../components/cars/addcarItem.vue'
import Goodsdetail from '../components/project/goodsDetails.vue'
import cs from '../components/test.vue'
import Carput from '../components/cars/carput.vue'

Vue.use(VueRouter)
const routes = [
	{path: '/test', component: cs},
  {path: '/', redirect: '/login'},
  {path: '/login', component: Login},
  {path: '/elementUI',component: ElementUI},
  {path: '/home',component: Home},
  {path: '/goodsDetails',component: Goodsdetail},
  {path: '/register',component:Register},
  {path: '/home',component: Home,children:[
     /* 车型查询*/
     {path: '/put',component:Carput},
     {path: '/carmall',component:Carmall,children:[
       {path: '/cardetail',component:Cardetail},
       {path: '/carmall/addcarItem',component:AddcarItem},
     ]},
     {path: '/storehousebig',component:Storehousebig},
     {path: '/storehousesmall',component:Storehousesmall},
     {path: '/user',component:User},
     {path: '/customer',component:Customer},
     {path: '/supplier',component:Supplier},
     {path: '/autocity',component:AutoCity},
     {path: '/flashguest',component:Flashguest},
     {path: '/privatecar',component:Privatecar},
     {path: '/show',component:Show},
     {path: '/ylbbing',component:Ylbbing},
     {path: '/itemall',component:ItemAll,children:[
       {path: '/item',component:Item},
       {path: '/yinlianbang1',component:Yinlianbang1},
       {path: '/itemall/addyinglianbang',component:AddYinglianbang},
     ]},
     {path: '/itemcat',component:ItemCat},
  ]},
  {path: '/index',component:Index},
  {path: '/shopping',component:Shopping,children:[

  ]},
  {path: '/list',component:List,children:[

  ]},
  {path: '/about',component:About},
  {path: '/car',component:Car},
  {path: '/yinlianbang',component:Yinlianbang},
  /* 个人中心*/
  {path: '/me',component:Me,children:[
    {path: '/carshopping',component:Carshopping},
    {path: '/personalData',component:PersonalData},
    {path: '/usernew',component:Usernew},
    {path: '/favorites',component:Favorites},
  ]},


]

const router = new VueRouter({
  routes
})
/* 参数说明:
 to  到哪里去
 from    从哪里来
 next    请求放行
 拦截器策略:
 1.如果用户访问/login登录页面,直接放行
 2.如果用户访问其他的页面,校验是否有token
 有token   放行
 没有token   跳转到登录页面*/
 // router.beforeEach((to,from,next) => {
 //   if(to.path === '/login') return next()
 //   //获取token数据信息
 //   let token = window.sessionStorage.getItem('token')
 //   if(token === null || token === ''){
 //     return next("/login")
 //   }
 //   //放行请求
 //   next()
 // })
export default router
